import React, { Component } from 'react';
import Foot from './Foot'
import Head from './Head'
import List from './List'
import { getAllItemAction } from './../store/actionCreators'
import { connect } from 'react-redux'

class Todo extends Component {
    constructor(props) {
        super(props)
    }

    render() {
        return (
            <div className="App" >
                { /* 头部 */}
                <Head />
                { /* 列表 */}
                <List />
                { /* 底部 */}
                <Foot />
            </div>
        )
    }

    componentDidMount() {
        this.props.reqTodoList();
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
        reqTodoList() {
            const action = getAllItemAction();
            dispatch(action)
        }
    }
}

export default connect(null, mapDispatchToProps)(Todo);